import instance from "@/utils/request";
interface addAddressItem {
    userid:string,
    name:string,
    tel:string,
    province:string,
    city:string,
    county:string,
    addressDetail:string,
    isDefault:boolean
}
//添加
export function addAddress(data: addAddressItem) {
    return instance({
        url: '/address/add',
        method: 'post',
        data,
        headers: {
            'Content-Type': 'application/json'
        }
    })
}
//默认地址
export function getDefaultAddress(data:{userid:string}){
    return instance({
        url: '/address/defaultAddress',
        method: 'get',
        params:data,
    })
}
interface updateAddressItem {
    addressid:string,
    userid:string,
    name:string,
    tel:string,
    province:string,
    city:string,
    county:string,
    addressDetail:string,
    isDefault:boolean
}
//更新
export function updateAddress(data:updateAddressItem){
    return instance({
        url: '/address/update',
        method: 'post',
        data,
        headers: {
            'Content-Type': 'application/json'
        }
    })
}
//获取地址列表
export function getAllAddress(data:{userid:string}){
    return instance({
        url: '/address/list',
        method: 'get',
        params:data,
    })
}
//删除
export function deleteAddress(data:{addressid:string}){
    return instance({
        url: '/address/delete',
        method: 'post',
        data,
        headers: {
            'Content-Type': 'application/json'
        }
    })
}